var express = require("express");
var app = express();

//解决跨域问题的代码
app.all("*", function(req, res, next) {
  res.header("Access-Control-Allow-Origin", "*");
  res.header("Access-Control-Allow-Headers", "X-Requested-With");
  res.header("Access-Control-Allow-Methods", "PUT,POST,GET,DELETE,OPTIONS");
  res.header("X-Powered-By", "3.2.1");
  res.header("Content-Type", "application/json;charset=utf-8");
  next();
});

//获得可拖动的列表按钮的接口
app.get("/get_tabBtn_list", function(req, res) {
  var tabList = [
    "推荐",
    "居家生活",
    "服饰鞋包",
    "美食酒水",
    "个护清洁",
    "母婴亲子",
    "全球特色"
  ];
  res.send(tabList);
});

//获得轮播图图片数据
app.get("/get_imgUrl", function(req, res) {
  var tabUrl = [
    "https://yanxuan.nosdn.127.net/8791af5b802edd4a26ac79146cff50cc.png?type=webp&imageView&quality=75&thumbnail=750x0",
    "https://yanxuan.nosdn.127.net/194d6e3c4112c7d71df4bdec7670f490.jpg?type=webp&imageView&quality=75&thumbnail=750x0",
    "https://yanxuan.nosdn.127.net/472b0d1eafd60edab1c811a80ba42d92.jpg?type=webp&imageView&quality=75&thumbnail=750x0",
    "https://yanxuan.nosdn.127.net/7a33ec04aadabc59e5e2875e59c310fd.jpg?type=webp&imageView&quality=75&thumbnail=750x0"
  ];
  res.send(tabUrl);
});

//获取九宫格图片
app.get("/get_nineImg", function(req, res) {
  var nineImg = [
    {
      url: require("../src/assets/goods_icon/9img1.png"),
      goods_txt: "新品首发"
    },
    {
      url: require("../src/assets/goods_icon/9img2.png"),
      goods_txt: "居家生活"
    },
    {
      url: require("../src/assets/goods_icon/9img3.png"),
      goods_txt: "服饰鞋包"
    },
    {
      url: require("../src/assets/goods_icon/9img4.png"),
      goods_txt: "美食洒水"
    },
    {
      url: require("../src/assets/goods_icon/9img5.png"),
      goods_txt: "个护清洁"
    },
    {
      url: require("../src/assets/goods_icon/9img6.png"),
      goods_txt: "母婴亲子"
    },
    {
      url: require("../src/assets/goods_icon/9img7.png"),
      goods_txt: "运动旅行"
    },
    {
      url: require("../src/assets/goods_icon/9img8.png"),
      goods_txt: "数码家电"
    },
    {
      url: require("../src/assets/goods_icon/9img9.png"),
      goods_txt: "全球特色"
    },
    {
      url: require("../src/assets/goods_icon/9img10.gif"),
      goods_txt: "好货抄底"
    }
  ];
  res.send(nineImg);
});

app.listen(2121, function() {
  console.log("监听2121成功");
});
